package com.yanti.controller;

import com.yanti.domain.ResponseResult;
import com.yanti.service.QuestionChaptersService;
import com.yanti.service.SubjectsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/chapter")
public class ChapterController {

    @Autowired
    private QuestionChaptersService questionChaptersService;

    @Autowired
    private SubjectsService subjectsService;

    @GetMapping("/getAllSubjects")
    public ResponseResult getAllSubjects(){
        return subjectsService.getAllSubject();
    }
    @GetMapping("/getAllChapter")
    public ResponseResult getAllChapter(){
        return questionChaptersService.getAllChapter();
    }

    @GetMapping("/getChapterById/{id}")
    public ResponseResult getChapterById(@PathVariable String id){
        return questionChaptersService.getChapterById(id);
    }

    @GetMapping("/getChaptersBySubjectId/{subjectId}")
    public ResponseResult getChaptersBySubjectId(@PathVariable String subjectId){
        return questionChaptersService.getChaptersBySubjectId(subjectId);
    }
}